#!/usr/bin/env python
#
# common.py is part of pyStrips
# Copyright (C) - 2009 - Juan B. Cabral <jbcabral_89@yahoo.com.ar>

# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

################################################################################
# DOCS
################################################################################

'''Constants for pyStrips'''

################################################################################
# IMPORTS
################################################################################

import re


################################################################################
# RESERVED WORDS
################################################################################

# Predicates
RW_PREDICATES = "predicates"

# Asignation
RW_AND = "&"
RW_BLOCK_START = ":"

# Operators
RW_OPERATOR = "op"
RW_LIST_PRECONDITION = "pre"
RW_LIST_DELETE = "del"
RW_LIST_ADD = "add"

# States
RW_STATE = "state"
RW_STATE_GOAL = "goal"
RW_STATE_INIT = "init"
RW_STATE_INTERNAL = "internal"

# Comment
RW_COMMENT = "#"

# ALL WORDS
RESERVED_WORDS = [rw for rw_name, rw in locals().items() 
                  if rw_name.startswith("RW_")]

################################################################################
# PATTERNS
################################################################################

RE_PREDICATE = re.compile("^[ ]*[a-zA-Z0-9_]+[ ]+[a-zA-Z0-9_ ]+$")

RE_OPERATOR = re.compile("^[ ]*%s[ ]+[a-zA-Z0-9_ ]+$" % RW_OPERATOR)     
    
RE_STATE = re.compile("^[ ]*%s[ ]+(%s|%s)[ ]+[a-zA-Z0-9_]+$" % 
                      (RW_STATE, RW_STATE_INIT, RW_STATE_GOAL))
                                            
RE_INVALID_CHARS = re.compile("[^a-zA-Z0-9%s%s_\s]+" % 
                            (RW_BLOCK_START, RW_AND))


################################################################################
# MAIN
################################################################################
    
if __name__ == '__main__':
    print(__doc__)
